package demo3.innerclassdemo2;

/**
 * Created with IntelliJ IDEA.
 * Description:外部类和内部类变量同名的使用情况
 * User: 阿宾
 * Date: 2024-10-16
 * Time: 09:53
 */
public class Outer {
    private int a = 10;

    public void show(){
        System.out.println(a);
        //外部类不能直接访问内部类成员，只能先创建内部类对象
        Inner inner = new Inner();
        inner.show();
        System.out.println(inner.a);

    }
    public class Inner{
        private int a = 30;
        public void show(){
            int a = 40;
            System.out.println(a);//40
            System.out.println(this.a);//30
            System.out.println(Outer.this.a);//10
        }
    }
}
